<?php ob_start() ?>

    <!-- 主内容区 -->
    <div class="pt-16 pb-8 min-h-screen">
        <div class="container mx-auto px-4">
            <!-- 页面标题 -->
            <div class="mt-8 mb-6 flex flex-col md:flex-row md:items-center md:justify-between">
                <div>
                    <h2 class="text-[clamp(1.5rem,3vw,2.5rem)] font-bold text-gray-800">用户点击数据列表</h2>
                    <p class="text-gray-600 mt-1">显示所有用户点击数据</p>
                </div>
                <!-- 下载按钮 -->
                <a href="<?= base_url('/record-activity/export-click-csv') ?>" class="bg-blue-500 hover:bg-blue-600 text-white py-2 px-4 rounded-md">下载用户点击数据 CSV</a>
            </div>

            <!-- 成功和错误提示 -->
            <?php if (session()->has('success')): ?>
                <div class="text-green-500 mb-4"><?= session('success') ?></div>
            <?php endif; ?>
            <?php if (session()->has('error')): ?>
                <div class="text-red-500 mb-4"><?= session('error') ?></div>
            <?php endif; ?>

            <!-- 页面链接列表 -->
            <div class="bg-white rounded-xl shadow-lg p-6">
                <table class="w-full">
                    <thead>
                        <tr>
                            <!-- 这里可以根据实际的默认字段添加更多列 -->
                            <th class="text-left pb-2">序号</th>
                            <th class="text-left pb-2">活动类型</th>
                            <th class="text-left pb-2">用户网络地址</th>
                            <th class="text-left pb-2">用户点击的研学地编号</th>
                            <th class="text-left pb-2">用户点击的研学地名称</th>
                            <th class="text-left pb-2">活动时间</th>
                            <!-- 可以继续添加其他默认字段 -->
                        </tr>
                    </thead>
                    <tbody>
                        <?php $index = 1; foreach ($clickActivities as $activity): ?>
                            <tr>
                                <td class="py-2"><?= $index++ ?></td>
                                <td class="py-2"><?= $activity['action_type_text'] ?? '' ?></td>
                                <td class="py-2"><?= $activity['ip_address'] ?? '' ?></td>
                                <td class="py-2"><?= $activity['location_order'] ?? '' ?></td>
                                <td class="py-2"><?= $activity['location_name'] ?? '' ?></td>
                                <td class="py-2"><?= $activity['action_time'] ?? '' ?></td>
                            </tr>
                        <?php endforeach; ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>

    <!-- 主内容区 -->
    <div class="pt-16 pb-8 min-h-screen">
        <div class="container mx-auto px-4">
            <!-- 页面标题 -->
            <div class="mt-8 mb-6 flex flex-col md:flex-row md:items-center md:justify-between">
                <div>
                    <h2 class="text-[clamp(1.5rem,3vw,2.5rem)] font-bold text-gray-800">用户停留数据列表</h2>
                    <p class="text-gray-600 mt-1">显示所有用户停留数据</p>
                </div>
                <!-- 下载按钮 -->
                <a href="<?= base_url('/record-activity/export-stay-csv') ?>" class="bg-blue-500 hover:bg-blue-600 text-white py-2 px-4 rounded-md">下载用户停留数据 CSV</a>
            </div>

            <!-- 成功和错误提示 -->
            <?php if (session()->has('success')): ?>
                <div class="text-green-500 mb-4"><?= session('success') ?></div>
            <?php endif; ?>
            <?php if (session()->has('error')): ?>
                <div class="text-red-500 mb-4"><?= session('error') ?></div>
            <?php endif; ?>

            <!-- 页面链接列表 -->
            <div class="bg-white rounded-xl shadow-lg p-6">
                <table class="w-full">
                    <thead>
                        <tr>
                            <!-- 这里可以根据实际的默认字段添加更多列 -->
                            <th class="text-left pb-2">序号</th>
                            <th class="text-left pb-2">活动类型</th>
                            <th class="text-left pb-2">用户网络地址</th>
                            <th class="text-left pb-2">用户停留的研学地编号</th>
                            <th class="text-left pb-2">用户停留的研学地名称</th>
                            <th class="text-left pb-2">停留时间(秒)</th>
                            <th class="text-left pb-2">活动时间</th>
                            <!-- 可以继续添加其他默认字段 -->
                        </tr>
                    </thead>
                    <tbody>
                        <?php $index = 1; foreach ($stayActivities as $activity): ?>
                            <tr>
                                <td class="py-2"><?= $index++ ?></td>
                                <td class="py-2"><?= $activity['action_type_text'] ?? '' ?></td>
                                <td class="py-2"><?= $activity['ip_address'] ?? '' ?></td>
                                <td class="py-2"><?= $activity['location_order'] ?? '' ?></td>
                                <td class="py-2"><?= $activity['location_name'] ?? '' ?></td>
                                <td class="py-2"><?= $activity['duration'] ?? '' ?></td>
                                <td class="py-2"><?= $activity['action_time'] ?? '' ?></td>
                            </tr>
                        <?php endforeach; ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>

<?php $content = ob_get_clean() ?>

<?= view('layouts/base', ['content' => $content]) ?>